import React from "react";
import PropType from "prop-types";
import Icon from "../../components/Icon/index";
import cx from "classnames";

export default class Item extends React.Component {
  render() {
    const { text = "", linkText, onClick, ceiling, suffix, hideIcon, className } = this.props;
    const cls = cx(`box-item${+text === 0 ?' data-empty':''}`, {
      [className]: !!className,
    });
    return (
        <div className={cls} onClick={onClick}>
          {text === '' ? null: <div className="box-item-text">
            <span>
              {Number(text) > ceiling ? ceiling + "+" : text}
              <span className="box-item-text-suffix">{suffix}</span>
            </span>
          </div>}
          {
            <div className="box-item-link">
              <a>
                {linkText}
                {/* {onClick && <Icon type="right" />} */}
              </a>
            </div>
          }
        </div>
    );
  }
}

Item.propTypes = {
  text: PropType.oneOfType([PropType.string, PropType.number]),
  linkText: PropType.oneOfType([PropType.string, PropType.element]),
  onClick: PropType.func,
  ceiling: PropType.number,
  suffix: PropType.string
};
